home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 47.7z / BS1 part 47 / ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].7z / ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].adf / piarc.lzh.parta / HLPublish.rexx < prev    next >
OS/2 REXX Batch file  |  1994-03-17  |  5KB  |  175 lines

  1. /*
  2.  * HLPublish.rexx
  3.  *
  4.  *  Written by: Pete Patterson & Ben Williams
  5.  * Last Update: April 18, 1992
  6.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  7.  * ---------------------------------------------------------------------------
  8.  *    Revision: 1.02
  9.  */
  10. parse arg filename buffer
  11. call pragma('stack',20000);
  12.  
  13. /*
  14.  * open rexxsupport.library -- needed for some functions
  15.  */
  16. if ~show('L',"rexxsupport.library") then do
  17.   if addlib('rexxsupport.library',0,-30,0) then do
  18.       /* everything's ok */
  19.     end;
  20.   else do
  21.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  22.     say 'Cannot operate HLPublish.rexx without this library - sorry!';
  23.     exit 10;
  24.     end;
  25.   end;
  26.  
  27. /*
  28.  * This will automatically direct the script to the proper
  29.  * software, if it is running.
  30.  */
  31. prtnme = 'IP_Port'; /* assume Image Professional */
  32. if show('P','IP_Port') = 0 then do
  33.   if show('P','IM_Port') = 0 then do
  34.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  35.     say "This script requires IP, IM or IM F/c to run!";
  36.     exit(20);
  37.     end;
  38.   else do
  39.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  40.     end;                 /* We make em, user's break em.          */
  41.   end;
  42.  
  43.   /*
  44.    * This code attempts to read a file called "picmdpath" from REXX:
  45.    * If it can't find it, the script will assume that the commands
  46.    * associated with this PI Module are in "c:". If the file exists,
  47.    * the script will look in the path that is specified in the file.
  48.    * If you create this file, you MUST put a complete, correct path
  49.    * in it; if the commands are in a sub-directory, you have to put
  50.    * the trailing slash on the path (like, device:dir/).
  51.    * 
  52.    */
  53.   cmdpath = 'c:';
  54.   if open(fhandle,'rexx:picmdpath','read') then  /* open the file */
  55.     do
  56.       cmdpath = readln(fhandle);
  57.       call close(fhandle);  /* close the file    */
  58.     end
  59.  
  60. options;
  61. address;
  62.  
  63.   address(prtnme);
  64.   options results;
  65.   'current';
  66.   bufdata = result; /* get name of buffer, if there is one */
  67.   parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum;
  68.   if bname ~= '<none>' then do
  69.     bufname = bname;
  70.     end;
  71.  
  72.   address(prtnme);
  73.  
  74. 'tofront';
  75.  
  76. options results;
  77. 'gadgets "Publish","as RGB","Publish","as CMYK","Publish","as GREY","Publish","as B&W"';
  78. ptype = result-1;
  79. options;
  80. if ptype < 0 then do
  81.   address;
  82.   exit 0;
  83.   end
  84.  
  85.   if ptype < 3 then do
  86.     options results;
  87.     'askprop '||'"Number of bitplanes per color channel?" 8 1 8'
  88.     planes = result;
  89.     options;
  90.   end
  91.  
  92.   if ptype = 3 then do
  93.     options results;
  94.     'askprop '||'"Luma threshold for black level?" 50 1 100'
  95.     planes = result;
  96.     options;
  97.   end
  98.  
  99.   if buffer = '' then do
  100.     options results;
  101.     'jackin';
  102.     jackadr = result;
  103.     options;
  104.     end;
  105.   else do
  106.     options results;
  107.     'backin '||buffer;
  108.     jackadr = result;
  109.     options;
  110.     end;
  111.  
  112.   'wbtofront';
  113.   'lockimage '||bnum;
  114.   address command cmdpath||'HLPublish '||jackadr||' '||ptype||' '||planes;
  115.   'unlockimage '||bnum;
  116.  
  117.   address(prtnme);
  118.   'imtofront';
  119.   'finish';
  120.   address;
  121.  
  122.   exit 0;
  123.  
  124. /*
  125.  * gimmepath
  126.  *
  127.  * This takes the provided argument and sucks the path out of it, then
  128.  * returns that path to the caller, sans file name.
  129.  */
  130. gimmepath:
  131.   arg fullnamegx;
  132.     tempgx = reverse(fullnamegx);
  133.     lengx = length(fullnamegx);   /* get length of string */
  134.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  135.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  136.     seploc = 0; /* assumes current dir, no path supplied */
  137.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  138.       seploc = (lengx - slashdex)+1;
  139.       end;
  140.     else do
  141.       if colondex ~= 0 then do /* we assume we are on a device */
  142.         seploc = (lengx - colondex)+1;
  143.         end;
  144.       end;
  145.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  146.   gxpath = left(fullnamegx,seploc);
  147.   return(gxpath);
  148.  
  149. /*
  150.  * Since this script can't be expected to know where the CD of the user
  151.  * is when this cmd is invoked, we have to check the path the user
  152.  * provides - if it's not specified right from a root, then we have
  153.  * to make it a complete specification from the root.
  154.  */
  155. expandfilename:
  156.   parse arg jfile;
  157.   if index(jfile,':') = 0 then do
  158.     curdir = pragma(D);
  159.     if right(curdir,1) ~= ':' then do
  160.       if right(curdir,1) ~= '/' then do
  161.         if curdir ~= '' then do
  162.           curdir = curdir || '/';
  163.           end;
  164.         end;
  165.       end;
  166.     jfile = curdir||jfile;
  167.     end;
  168.   return(jfile);
  169.  
  170. rvalue:
  171.   wordnum = c2d(readch(fhandle,1)) * 256;
  172.   wordnum = wordnum + c2d(readch(fhandle,1));
  173.   return wordnum;
  174.  
  175.